/**
 * 
 */
package hihocoder;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 子树中的最小权值 {

	static class Node {
		int val;
		int minVal;
		Node parent;
		ArrayList<Node> childs = new ArrayList<>();

		void changeVal(int newVal) {
			int oldVal = this.val;
			this.val = newVal;
			if (oldVal == newVal) {// 无需计算
				return;
			}
			if (oldVal > newVal) {// 不会更关心最小值
				if (this.minVal <= newVal) {
					return;
				}
			} else if (oldVal < newVal) {
				if (oldVal != minVal) {
					return;
				}
			}
			Node curNode = this;
			while (curNode != null) {
				// 如果min值没有更改，则可以break
				int oldMin = curNode.minVal;
				int newMin = curNode.val;
				for (Node node : curNode.childs) {
					newMin = Math.min(newMin, node.minVal);
				}
				if (oldMin == newMin) {
					break;
				}
				curNode.minVal = newMin;
				curNode = curNode.parent;
			}
		}
	}

	static int getMin(Node root) {
		int min = root.val;
		for (Node node : root.childs) {
			min = Math.min(min, getMin(node));
		}
		root.minVal = min;
		return min;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		Node[] nodes = new Node[N];
		for (int i = 0; i < N; i++) {
			nodes[i] = new Node();
			nodes[i].val = scanner.nextInt();
		}
		for (int i = 1; i < N; i++) {
			int parent = scanner.nextInt() - 1;
			nodes[i].parent = nodes[parent];
			nodes[parent].childs.add(nodes[i]);
		}
		getMin(nodes[0]);
		int Q = scanner.nextInt();
		for (int i = 0; i < Q; i++) {
			int type = scanner.nextInt();
			int x = scanner.nextInt() - 1;
			if (type == 1) {
				int u = scanner.nextInt();
				nodes[x].changeVal(u);
			} else {
				System.out.println(nodes[x].minVal);
			}
		}
	}

}
